#ifndef UTILS_H
#define UTILS_H

#include <QFileDialog>
#include <QDesktopServices>
#include <QMessageBox>
#include <QAxObject>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QEventLoop>
#include <QHttpPart>
#include <QJsonObject>
#include <QList>
#include <QTreeWidget>
#include <Entity/Post.h>
#include <Entity/User.h>
#include <QHash>
#include <QJsonArray>
#include <QJsonDocument>
#include <QTableWidget>
#include <QThread>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QWidget>
#include <QPushButton>
#include <QTreeWidgetItem>
#include <QObject>
#include <QMainWindow>
#include <QMap>


class Utils : public QMainWindow
{
    Q_OBJECT
public:
    Utils();

    static QString baseUrl;
    QMap<QString,QString> backShowStyle;
    QStringList backShowStyleKeys;

    User* getUser(QByteArray bytes);
    User* getUserByJsonObj(QJsonObject obj);
    Dept getDept(QJsonObject jsonDept);
    Role getRole(QJsonObject jsonRole);
    Post getPost(QJsonObject jsonPost);

    void load();
    //设置用户管理表格
    void settableWidget_userManager(QList<User> *userList,QTableWidget *tableWidget,QStringList tableColimnList);
    //递归过滤树节点
    void filterTreeWidget(QTreeWidgetItem *item,QString text);
    //导出excel
    void exportExcel(QTableWidget *table,QString title);

    //上传文件
    QNetworkReply *uploadFile(QString filePath,QString url);

    QHash<QString,int> routerMap;

    //api返回结果检查
    void requestCheck(QByteArray *data);

    //QTreeWidget相关
    void updateParentItem(QTreeWidgetItem *item);
    void selectAll(QTreeWidgetItem *item);
    void unSelectAll(QTreeWidgetItem *item);
    void getMenuIds(QTreeWidgetItem *item,QList<int> *menuIds);
    //检测所属权限
    void setOwnMenu(int id,QTreeWidgetItem *item);
    //选择所有子节点
    void selectAllSonNode(QTreeWidgetItem *item);

    QByteArray *getDictType(QString type);

signals:
    void back401();
    void stateChangeSuccess();
};

#endif // UTILS_H
